import { addCsvData } from "../csv";
import { touchEventData } from "./event";

export enum SettingAction {
    Click = 'Click', // 点击事件
    LongClick = 'LongClick', // 长按事件
    Swipe = 'Swipe', // 滑动事件
}

// 设置Widget
export enum SettingWidget {
    SettingMenuItem = 'SettingMenuItem', // 菜单
    SettingSwitch = 'SettingSwitch', // 开关
    SettingSlider = 'SettingSlider', // 滑动条
    SettingAdjust = 'SettingAdjust', // 调节项
    SettingBtn = 'SettingBtn', // 按钮
}

// 开关事件
export enum SettingSwitchEventID {
    SuspensionComfort = 'SuspensionComfort', // 悬架舒适度Switch
    SteeringMode = 'SteeringMode', //转向模式
    EnergyRecovery = 'EnergyRecovery', //能量回收
    LightControl = 'LightControl', //车灯控制
    Bluetooth = 'Bluetooth', //蓝牙
}

// 滑动事件
export enum SettingSliderEventID {
    SoundSlider = 'SoundSlider', // 声音滑动条
    LightSlider = 'LightSlider', //亮度滑动条
    fanSlider = 'FanSlider', // 风扇滑动条
}

//调节事件
export enum SettingAdjustEventID {
    mainAcUp = 'mainAcUp', // 主空调调节上
    mainAcDown = 'mainAcDown', // 主空调调节下
    passengerAcUp = 'passengerAcUp', // 副驾驶空调调节上
    passengerAcDown = 'passengerAcDown', // 副驾驶空调调节下
}

//按钮事件
export enum SettingBtnEventID {
    fan = 'fan', // 风量按钮
    glassBlow = 'glassBlow', //  玻璃吹风
}

// 设置事件
function eventSetting(action: SettingAction.Click, widget: SettingWidget.SettingMenuItem, eventKey: `${SettingWidget.SettingMenuItem}${number}`, value: string): void;
function eventSetting(action: SettingAction.Click, widget: SettingWidget.SettingSwitch, eventKey: SettingSwitchEventID, value: string): void;
function eventSetting(action: SettingAction.Click, widget: SettingWidget.SettingAdjust, eventKey: SettingAdjustEventID, value: string): void;
function eventSetting(action: SettingAction.Click, widget: SettingWidget.SettingBtn, eventKey: SettingBtnEventID, value: string): void;

function eventSetting(action: SettingAction.LongClick, widget: SettingWidget.SettingBtn, eventKey: SettingBtnEventID, value: string): void;

function eventSetting(action: SettingAction.Swipe, widget: SettingWidget.SettingSlider, eventKey: SettingSliderEventID, value: touchEventData): void;

function eventSetting(action: SettingAction, widget: SettingWidget | null, eventKey: any, value?: any): void {
    const data = { app: "Setting", event_key: eventKey, data_json: { action, widget_type: widget, widget_id: eventKey, value } };
    addCsvData(data);
}
export { eventSetting }